@using Microsoft.AspNetCore.Identity
@using EIMS.Models.Identity
@inject SignInManager<ApplicationUser> SignInManager
@inject UserManager<ApplicationUser> UserManager

<ul class="navbar-nav">
@if (SignInManager.IsSignedIn(User))
{
    var user = await UserManager.GetUserAsync(User);
    var displayName = user?.DisplayName ?? User.Identity?.Name;

    <li class="nav-item dropdown">
        <a class="nav-link dropdown-toggle text-dark" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
            <i class="bi bi-person-circle"></i> @displayName
        </a>
        <ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
            <li><a class="dropdown-item" asp-area="" asp-controller="Account" asp-action="Profile">个人资料</a></li>
            <li><a class="dropdown-item" asp-area="" asp-controller="Account" asp-action="ChangePassword">修改密码</a></li>
            <li><hr class="dropdown-divider"></li>
            <li>
                <form class="form-inline" asp-area="" asp-controller="Account" asp-action="Logout" method="post">
                    <button type="submit" class="dropdown-item">退出登录</button>
                </form>
            </li>
        </ul>
    </li>
}
else
{
    <li class="nav-item">
        <a class="nav-link text-dark" asp-area="" asp-controller="Account" asp-action="Register">注册</a>
    </li>
    <li class="nav-item">
        <a class="nav-link text-dark" asp-area="" asp-controller="Account" asp-action="Login">登录</a>
    </li>
}
</ul> 